//
//  ZCTool.m
//  zctx
//
//  Created by apple on 15/12/17.
//  Copyright © 2015年 sanliang. All rights reserved.
//

#import "ZCTool.h"

@implementation ZCTool

+ (void)timerFireMethod:(NSTimer*)theTimer
{
    UIAlertView *promptAlert = (UIAlertView*)[theTimer userInfo];
    [promptAlert dismissWithClickedButtonIndex:0 animated:NO];
    promptAlert =NULL;
}

+(void)showAlert:(NSString *)titleStr
{
    UIAlertView *promptAlert = [[UIAlertView alloc] initWithTitle:nil message:titleStr delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
    [NSTimer scheduledTimerWithTimeInterval:0.5f
                                     target:self
                                   selector:@selector(timerFireMethod:)
                                   userInfo:promptAlert
                                    repeats:NO];
    [promptAlert show];
}


#pragma mark AppStore 评分弹层
+(void)gotoAppStore{
    
    int count = [UserModel.useCount intValue];
    count ++;
    
    NSLog(@"count11 = %d",count);
    UserModel.useCount = [NSString stringWithFormat:@"%d",count];
    if (count == 20) {
        UserModel.mainCount = @"20";
        [self showDisplayer]; //好评弹框
    }else if (count ==60){
        [self showDisplayer]; //好评弹框
    }else if (count == 140){
        int CountOne = 100 +count;
        UserModel.mainCount = [NSString stringWithFormat:@"%d",CountOne];
        [self showDisplayer]; //好评弹框
    }else if (count == [UserModel.mainCount intValue]){
        int countTwo = [UserModel.mainCount intValue];
        countTwo +=100;
        UserModel.mainCount = [NSString stringWithFormat:@"%d",countTwo];
        [self showDisplayer]; //好评弹框
    }
}
+(void)showDisplayer{
    [IGDisplayer showDisplayerWithPositionType:IGDisplayerPositionTypeCenter
                                     titleText:@"给个评价吧"
                                   contentText:@"您的评价是夜空中最闪亮的星，我们会努力做得更好！"
                             cancelButtonTitle:@"现在没空"
                                    buttonList:@[@"马上好评",@"我要吐槽"]
                             handleActionBlock:^(IGDisplayer *displayer, NSInteger index) {
                                 NSString *str = [NSString stringWithFormat:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=1039759996" ];
                                 if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0)){
                                     str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id1039759996"];
                                 }
                                 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
                             }];
}


@end
